﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Transitions;
using System.Windows.Forms;

namespace UIT_CV_Management
{
    public partial class LapHoSoForm : Form
    {
        // USer Login
        public User userLogin;

        //******************************************************
        // Ly Lich So Luoc
        private UserControlLyLichSoLuoc UCLyLichSoLuoc;
        // Dai Hoc
        private List<UserControlDaoTaoDaiHoc> listUCDaiHoc = new List<UserControlDaoTaoDaiHoc>();
        // TrenDaiHoc
        private List<UserControlTrenDaiHoc> listUCTrenDaiHoc = new List<UserControlTrenDaiHoc>();
        // NgoaiNgua
        private List<UserControlNgoaiNgu> listUCNgoaiNgu = new List<UserControlNgoaiNgu>();
        // HocHam
        private List<UserControlHocHam> listUCHocHam = new List<UserControlHocHam>();
        // KhenThuong
        private List<UserControlKhenThuong> listUCKhenThuong = new List<UserControlKhenThuong>();
        // QuaTrinhHDKHKT
        private List<UserControlQuaTrinhHDKHKT> listUCQuaTrinhHDKHKT = new List<UserControlQuaTrinhHDKHKT>();
        // HoiNghiKHKT
        private List<UserControlHoiNghiKHKT> listUCHoiNghiKHKT = new List<UserControlHoiNghiKHKT>();


        //QuaTrinhDaoTao
        QuyTrinhDaoTao quaTrinhDaoTao;
        //HoatDongKHKT
        HoatDongKHKT hoatDongKHKT;

        //LyLichKhoaHoc
        LyLichKhoaHoc lyLichKhoaHoc;
        //******************************************************
        //check what user control is showing
        Boolean isLyLichSoLuocShowing = false;
        Boolean isDaiHocShowing = false;
        Boolean isTrenDaiHocShowing = false;
        Boolean isNgoaiNguShowing = false;
        Boolean isHocHamShowing = false;
        Boolean isKhenThuongShowing = false;
        Boolean isQuaTrinhHDKHKTShowing = false;
        Boolean isHoiNghiKHKTShowing = false;

        //******************************************************
        // index DaoTaoDaiHoc, TrenDaiHoc
        int _indexDaoTaoDaiHoc;
        int _indexTrenDaiHoc;
        int _indexNgoaiNgu;
        int _indexHocHam;
        int _indexKhenThuong;
        int _indexQuaTrinhHDKHKT;
        int _indexHoiNghiKHKT;

        // Database
        Database myDatabase = Database.shareDatabase;
        public LapHoSoForm()
        {
            InitializeComponent();
            
            // init language
            this.initLanguage();

            // add UCLyLichSoLuoc
            this.AddLyLichSoLuoc();

            //update Navigation
            this.updateNavigation();

            //add Usero
            userLogin = currentUser.logedinUser;

            this.lblSoYeuLiLich_Click(lblSoYeuLiLich, EventArgs.Empty);


        }

        private void initLanguage()
        {
            lblThemHoSoMoi.Text = Language._("LAPHOSO_FORM_THEMHOSOMOI_LBL");
            lblSoYeuLiLich.Text = Language._("LAPHOSO_FORM_LYLICHSOLUOC_LBL");
            lblDaoTaoDaiHoc.Text = Language._("LAPHOSO_FORM_DAOTAODAIHOC_LBL");
            lblDaoTaoTrenDaiHoc.Text = Language._("LAPHOSO_FORM_DAOTAOTRENDAIHOC_LBL");
            lblDaoTaoNgoaiNgu.Text = Language._("LAPHOSO_FORM_DAOTAONGOAINGU_LBL");
            lblDaoTaoHocHam.Text = Language._("LAPHOSO_FORM_DAOTAOHOCHAM_LBL");
            lblKhenThuong.Text = Language._("LAPHOSO_FORM_KHENTHUONG_LBL");
            lblHoatDongKHKT.Text = Language._("LAPHOSO_FORM_HOATDONGKHKT_LBL");
            lblHoiNghiKHKT.Text = Language._("LAPHOSO_FORM_HOINGHIKHKT_LBL");
            btnTiepTuc.Text = Language._("LAPHOSO_FORM_TIEPTUC_LBL");
            btnQuayLai.Text = Language._("LAPHOSO_FORM_QUAYLAI_LBL");

            //titile form
            this.Text = Language._("LAPHOSO_FORM_TITLE");
        }

        #region Add/Remove UserControl
        public void AddLyLichSoLuoc()
        {
            if (UCLyLichSoLuoc == null)
            {
                UCLyLichSoLuoc = new UserControlLyLichSoLuoc();
            }
            // set LyLichSoLuoc is showing
            isLyLichSoLuocShowing = true;

            // disable button
            buttonPhai.Enabled = false;
            buttonTrai.Enabled = false;

            UCLyLichSoLuoc.Dock = DockStyle.Fill;
            this.panelMain.Controls.Add(UCLyLichSoLuoc);

        }
        public void RemoveLyLichSoLuoc()
        {
            this.panelMain.Controls.Remove(UCLyLichSoLuoc);
            isLyLichSoLuocShowing = false;
        }

        public void AddDaiHoc(int _index)
        {
            UserControlDaoTaoDaiHoc UCDaiHoc;
            // add new 
            if (_index > listUCDaiHoc.Count - 1)
            {
                UCDaiHoc = new UserControlDaoTaoDaiHoc();
                // set Daihoc is showing
                isDaiHocShowing = true;

                // add
                listUCDaiHoc.Add(UCDaiHoc);
                this.panelMain.Controls.Add(UCDaiHoc);
                UCDaiHoc.Dock = DockStyle.Fill;
            }
            // add UCDaiHoc has adready created
            else if (_index >= 0 && _index < listUCDaiHoc.Count)
            {
                UCDaiHoc = listUCDaiHoc[_index];
                // set UCDaiHoc is showing
                isDaiHocShowing = true;

                // add to control
                UCDaiHoc.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCDaiHoc);
            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveDaiHoc(int _index)
        {
            if (_index >= 0 && _index < listUCDaiHoc.Count)
            {
                UserControlDaoTaoDaiHoc UCDaiHoc = listUCDaiHoc[_index];
                this.panelMain.Controls.Remove(UCDaiHoc);
            }
        }

        public void AddTrenDaiHoc(int _index)
        {
            UserControlTrenDaiHoc UCTrenDaiHoc;
            // add new 
            if (_index > listUCTrenDaiHoc.Count - 1)
            {
                UCTrenDaiHoc = new UserControlTrenDaiHoc();
                // set TrenDaihoc is showing
                isTrenDaiHocShowing = true;

                // add
                UCTrenDaiHoc.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCTrenDaiHoc);
                listUCTrenDaiHoc.Add(UCTrenDaiHoc);
            }
            // add UCTrenDaiHoc has adready created
            else if (_index >= 0 && _index < listUCTrenDaiHoc.Count)
            {
                UCTrenDaiHoc = listUCTrenDaiHoc[_index];
                // set UCTrenDaiHoc is showing
                isTrenDaiHocShowing = true;

                // add to control
                UCTrenDaiHoc.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCTrenDaiHoc);
            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveTrenDaiHoc(int _index)
        {
            if (_index >= 0 && _index < listUCTrenDaiHoc.Count)
            {
                UserControlTrenDaiHoc UCTrenDaiHoc = listUCTrenDaiHoc[_index];
                this.panelMain.Controls.Remove(UCTrenDaiHoc);
            }
        }

        public void AddNgoaiNgu(int _index)
        {
            UserControlNgoaiNgu UCNgoaiNgu;
            // add new 
            if (_index > listUCNgoaiNgu.Count - 1)
            {
                UCNgoaiNgu = new UserControlNgoaiNgu();
                // set NgoaiNgu is showing
                isNgoaiNguShowing = true;

                // add
                listUCNgoaiNgu.Add(UCNgoaiNgu);
                this.panelMain.Controls.Add(UCNgoaiNgu);
                UCNgoaiNgu.Dock = DockStyle.Fill;
            }
            // add UCNgoaiNgu has adready created
            else if (_index >= 0 && _index < listUCNgoaiNgu.Count)
            {
                UCNgoaiNgu = listUCNgoaiNgu[_index];
                // set UCNgoaiNgu is showing
                isNgoaiNguShowing = true;

                // add to control
                UCNgoaiNgu.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCNgoaiNgu);
            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveNgoaiNgu(int _index)
        {
            if (_index >= 0 && _index < listUCNgoaiNgu.Count)
            {
                UserControlNgoaiNgu UCNgoaiNgu = listUCNgoaiNgu[_index];
                this.panelMain.Controls.Remove(UCNgoaiNgu);
            }
        }

        public void AddHocHam(int _index)
        {
            UserControlHocHam UCHocHam;
            // add new 
            if (_index > listUCHocHam.Count - 1)
            {
                UCHocHam = new UserControlHocHam();
                // set HocHam is showing
                isHocHamShowing = true;

                // add
                UCHocHam.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCHocHam);
                listUCHocHam.Add(UCHocHam);
            }
            // add UCHocHam has adready created
            else if (_index >= 0 && _index < listUCHocHam.Count)
            {
                UCHocHam = listUCHocHam[_index];
                // set UCHocHam is showing
                isHocHamShowing = true;

                // add to control
                UCHocHam.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCHocHam);

            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveHocHam(int _index)
        {
            if (_index >= 0 && _index < listUCHocHam.Count)
            {
                UserControlHocHam UCHocHam = listUCHocHam[_index];
                this.panelMain.Controls.Remove(UCHocHam);
            }
        }

        public void AddKhenThuong(int _index)
        {
            UserControlKhenThuong UCKhenThuong;
            // add new 
            if (_index > listUCKhenThuong.Count - 1)
            {
                UCKhenThuong = new UserControlKhenThuong();
                // set KhenThuong is showing
                isKhenThuongShowing = true;

                // add
                UCKhenThuong.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCKhenThuong);
                listUCKhenThuong.Add(UCKhenThuong);
            }
            // add UCKhenThuong has adready created
            else if (_index >= 0 && _index < listUCKhenThuong.Count)
            {
                UCKhenThuong = listUCKhenThuong[_index];
                // set UCKhenThuong is showing
                isKhenThuongShowing = true;

                // add to control
                UCKhenThuong.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCKhenThuong);

            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveKhenThuong(int _index)
        {
            if (_index >= 0 && _index < listUCKhenThuong.Count)
            {
                UserControlKhenThuong UCKhenThuong = listUCKhenThuong[_index];
                this.panelMain.Controls.Remove(UCKhenThuong);
            }
        }

        public void AddQuaTrinhHDKHKT(int _index)
        {
            UserControlQuaTrinhHDKHKT UCQuaTrinhHDKHKT;
            // add new 
            if (_index > listUCQuaTrinhHDKHKT.Count - 1)
            {
                UCQuaTrinhHDKHKT = new UserControlQuaTrinhHDKHKT();
                // set QuaTrinhHDKHKT is showing
                isQuaTrinhHDKHKTShowing = true;

                // add
                UCQuaTrinhHDKHKT.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCQuaTrinhHDKHKT);
                listUCQuaTrinhHDKHKT.Add(UCQuaTrinhHDKHKT);
            }
            // add UCQuaTrinhHDKHKT has adready created
            else if (_index >= 0 && _index < listUCQuaTrinhHDKHKT.Count)
            {
                UCQuaTrinhHDKHKT = listUCQuaTrinhHDKHKT[_index];
                // set UCQuaTrinhHDKHKT is showing
                isQuaTrinhHDKHKTShowing = true;

                // add to control
                UCQuaTrinhHDKHKT.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCQuaTrinhHDKHKT);

            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveQuaTrinhHDKHKT(int _index)
        {
            if (_index >= 0 && _index < listUCQuaTrinhHDKHKT.Count)
            {
                UserControlQuaTrinhHDKHKT UCQuaTrinhHDKHKT = listUCQuaTrinhHDKHKT[_index];
                this.panelMain.Controls.Remove(UCQuaTrinhHDKHKT);
            }
        }

        public void AddHoiNghiKHKT(int _index)
        {
            UserControlHoiNghiKHKT UCHoiNghiKHKT;
            // add new 
            if (_index > listUCHoiNghiKHKT.Count - 1)
            {
                UCHoiNghiKHKT = new UserControlHoiNghiKHKT();
                // set HoiNghiKHKT is showing
                isHoiNghiKHKTShowing = true;

                // add
                UCHoiNghiKHKT.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCHoiNghiKHKT);
                listUCHoiNghiKHKT.Add(UCHoiNghiKHKT);
            }
            // add UCHoiNghiKHKT has adready created
            else if (_index >= 0 && _index < listUCHoiNghiKHKT.Count)
            {
                UCHoiNghiKHKT = listUCHoiNghiKHKT[_index];
                // set UCHoiNghiKHKT is showing
                isHoiNghiKHKTShowing = true;

                // add to control
                UCHoiNghiKHKT.Dock = DockStyle.Fill;
                this.panelMain.Controls.Add(UCHoiNghiKHKT);

            }

            // enable button
            if (_index == 0)
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = false;
            }
            else
            {
                buttonPhai.Enabled = true;
                buttonTrai.Enabled = true;
            }
        }
        public void RemoveHoiNghiKHKT(int _index)
        {
            if (_index >= 0 && _index < listUCHoiNghiKHKT.Count)
            {
                UserControlHoiNghiKHKT UCHoiNghiKHKT = listUCHoiNghiKHKT[_index];
                this.panelMain.Controls.Remove(UCHoiNghiKHKT);
            }
        }

        #endregion

        #region Update Navigation

        /// <summary>
        /// Update lại navigation Bar
        /// 
        /// </summary>
        private void updateNavigation()
        {
            // change all label's backcolor to Black Color
            lblSoYeuLiLich.ForeColor = Color.Black;
            lblDaoTaoDaiHoc.ForeColor = Color.Black;
            lblDaoTaoTrenDaiHoc.ForeColor = Color.Black;
            lblDaoTaoNgoaiNgu.ForeColor = Color.Black;
            lblDaoTaoHocHam.ForeColor = Color.Black;
            lblKhenThuong.ForeColor = Color.Black;
            lblHoatDongKHKT.ForeColor = Color.Black;
            lblHoiNghiKHKT.ForeColor = Color.Black;

            if (isLyLichSoLuocShowing)
            {
                // Set number Of page UC
                lblPages.Text = " 1 / 1";

                lblSoYeuLiLich.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.Blue;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isDaiHocShowing)
            {
                // Set number Of page UC
                lblPages.Text = (_indexDaoTaoDaiHoc + 1).ToString() + " / " + listUCDaiHoc.Count.ToString();

                lblDaoTaoDaiHoc.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.Blue;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isTrenDaiHocShowing)
            {
                // Set number Of page UC
                lblPages.Text = (_indexTrenDaiHoc + 1).ToString() + " / " + listUCTrenDaiHoc.Count.ToString();

                lblDaoTaoTrenDaiHoc.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.Blue;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isNgoaiNguShowing)
            {
                // Set number Of page UC
                lblPages.Text = (_indexNgoaiNgu + 1).ToString() + " / " + listUCNgoaiNgu.Count.ToString();

                lblDaoTaoNgoaiNgu.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.Blue;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isHocHamShowing)
            {
                // Set number Of page UC
                lblPages.Text = (_indexHocHam + 1).ToString() + " / " + listUCHocHam.Count.ToString();

                lblDaoTaoHocHam.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.Blue;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isKhenThuongShowing)
            {
                // Set number Of page UC
                lblPages.Text = (_indexKhenThuong + 1).ToString() + " / " + listUCKhenThuong.Count.ToString();

                lblKhenThuong.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.Blue;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isQuaTrinhHDKHKTShowing)
            {

                // Set number Of page UC
                lblPages.Text = (_indexQuaTrinhHDKHKT + 1).ToString() + " / " + listUCQuaTrinhHDKHKT.Count.ToString();

                lblHoatDongKHKT.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.Blue;
                lblHoiNghiKHKT.BackColor = Color.White;
                return;
            }
            if (isHoiNghiKHKTShowing)
            {
                // Set number Of page UC
                lblPages.Text = (_indexHoiNghiKHKT + 1).ToString() + " / " + listUCHoiNghiKHKT.Count.ToString();

                lblHoiNghiKHKT.ForeColor = Color.White;
                lblSoYeuLiLich.BackColor = Color.White;
                lblDaoTaoDaiHoc.BackColor = Color.White;
                lblDaoTaoTrenDaiHoc.BackColor = Color.White;
                lblDaoTaoNgoaiNgu.BackColor = Color.White;
                lblDaoTaoHocHam.BackColor = Color.White;
                lblKhenThuong.BackColor = Color.White;
                lblHoatDongKHKT.BackColor = Color.White;
                lblHoiNghiKHKT.BackColor = Color.Blue;
                return;
            }
        }

        /// <summary>
        /// Xoá tất cả các UC hiện có trên màn hình
        /// </summary>
        private void RemoveAllUC()
        {
            if (isLyLichSoLuocShowing)
                this.RemoveLyLichSoLuoc();
            if (isDaiHocShowing)
                this.RemoveDaiHoc(_indexDaoTaoDaiHoc);
            if (isTrenDaiHocShowing)
                this.RemoveTrenDaiHoc(_indexTrenDaiHoc);
            if (isNgoaiNguShowing)
                this.RemoveNgoaiNgu(_indexNgoaiNgu);
            if (isHocHamShowing)
                this.RemoveHocHam(_indexHocHam);
            if (isKhenThuongShowing)
                this.RemoveKhenThuong(_indexKhenThuong);
            if (isQuaTrinhHDKHKTShowing)
                this.RemoveQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);
            if (isHoiNghiKHKTShowing)
                this.RemoveHoiNghiKHKT(_indexHoiNghiKHKT);

            // False toàn bộ bool is[...]Showing
            isLyLichSoLuocShowing = false;
            isDaiHocShowing = false;
            isTrenDaiHocShowing = false;
            isNgoaiNguShowing = false;
            isHocHamShowing = false;
            isKhenThuongShowing = false;
            isQuaTrinhHDKHKTShowing = false;
            isHoiNghiKHKTShowing = false;

            // change all label's backcolor to Black Color
            lblSoYeuLiLich.ForeColor = Color.Black;
            lblDaoTaoDaiHoc.ForeColor = Color.Black;
            lblDaoTaoTrenDaiHoc.ForeColor = Color.Black;
            lblDaoTaoNgoaiNgu.ForeColor = Color.Black;
            lblDaoTaoHocHam.ForeColor = Color.Black;
            lblKhenThuong.ForeColor = Color.Black;
            lblHoatDongKHKT.ForeColor = Color.Black;
            lblHoiNghiKHKT.ForeColor = Color.Black;

        }

        private void lblSoYeuLiLich_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddLyLichSoLuoc();

            // update showing
            isLyLichSoLuocShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblSoYeuLiLich.ForeColor = Color.White;

            
           
        }

        private void lblDaoTaoDaiHoc_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddDaiHoc(0);
            _indexDaoTaoDaiHoc = 0;

            // update showing
            isDaiHocShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblDaoTaoDaiHoc.ForeColor = Color.White;

            
        }

        private void lblDaoTaoTrenDaiHoc_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddTrenDaiHoc(0);
            _indexTrenDaiHoc = 0;

            // update showing
            isTrenDaiHocShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblDaoTaoTrenDaiHoc.ForeColor = Color.White;

            
        }

        private void lblDaoTaoNgoaiNgu_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddNgoaiNgu(0);
            _indexNgoaiNgu = 0;

            // update showing
            isNgoaiNguShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblDaoTaoNgoaiNgu.ForeColor = Color.White;

            
        }

        private void lblDaoTaoHocHam_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddHocHam(0);
            _indexHocHam = 0;

            // update showing
            isHocHamShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblDaoTaoHocHam.ForeColor = Color.White;

            
        }

        private void lblKhenThuong_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddKhenThuong(0);
            _indexKhenThuong = 0;

            // update showing
            isKhenThuongShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblKhenThuong.ForeColor = Color.White;

            
        }

        private void lblHoatDongKHKT_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddQuaTrinhHDKHKT(0);
            _indexQuaTrinhHDKHKT = 0;

            // update showing
            isQuaTrinhHDKHKTShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblHoatDongKHKT.ForeColor = Color.White;

            
        }

        private void lblHoiNghiKHKT_Click(object sender, EventArgs e)
        {
            // xoá tất cả UC trên màn hình
            this.RemoveAllUC();

            // Thêm UC LyLichSoLuoc
            this.AddHoiNghiKHKT(0);
            _indexHoiNghiKHKT = 0;

            // update showing
            isHoiNghiKHKTShowing = true;

            //update navigation
            this.updateNavigation();

            // change foreColor to Color.White
            lblHoiNghiKHKT.ForeColor = Color.White;
        }

        #endregion

        private void buttonPhai_Click(object sender, EventArgs e)
        {
            // Button Phai for DaiHoc
            if (isDaiHocShowing)
            {
                UserControlDaoTaoDaiHoc UCDaiHoc = listUCDaiHoc[_indexDaoTaoDaiHoc];
                if (UCDaiHoc.isDaiHocOK())
                {
                    // remove previous UCDaiHoc
                    this.RemoveDaiHoc(_indexDaoTaoDaiHoc);

                    // Increament
                    _indexDaoTaoDaiHoc++;

                    // Add
                    this.AddDaiHoc(_indexDaoTaoDaiHoc);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // TrenDaiHoc
            if (isTrenDaiHocShowing)
            {
                UserControlTrenDaiHoc UCTrenDaiHoc = listUCTrenDaiHoc[_indexTrenDaiHoc];
                if (UCTrenDaiHoc.isTrenDaiHocOK())
                {
                    // remove previous UCTrenDaiHoc
                    this.RemoveTrenDaiHoc(_indexTrenDaiHoc);

                    // Increament
                    _indexTrenDaiHoc++;

                    // Add
                    this.AddTrenDaiHoc(_indexTrenDaiHoc);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // NgoaiNgu
            if (isNgoaiNguShowing)
            {
                UserControlNgoaiNgu UCNgoaiNgu = listUCNgoaiNgu[_indexNgoaiNgu];
                if (UCNgoaiNgu.isNgoaiNguOK())
                {
                    // remove previous UCNgoaiNgu
                    this.RemoveNgoaiNgu(_indexNgoaiNgu);

                    // Increament
                    _indexNgoaiNgu++;

                    // Add
                    this.AddNgoaiNgu(_indexNgoaiNgu);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                   MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // HocHam
            if (isHocHamShowing)
            {
                UserControlHocHam UCHocHam = listUCHocHam[_indexHocHam];
                if (UCHocHam.isHocHamOK())
                {
                    // remove previous UCHocHam
                    this.RemoveHocHam(_indexHocHam);

                    // Increament
                    _indexHocHam++;

                    // Add
                    this.AddHocHam(_indexHocHam);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                   MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            //Khen Thuong
            if (isKhenThuongShowing)
            {
                UserControlKhenThuong UCKhenThuong = listUCKhenThuong[_indexKhenThuong];
                if (UCKhenThuong.isKhenThuongOK())
                {
                    // remove previous UCKhenThuong
                    this.RemoveKhenThuong(_indexKhenThuong);

                    // Increament
                    _indexKhenThuong++;

                    // Add
                    this.AddKhenThuong(_indexKhenThuong);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                   MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // QuaTrinhHDKHKT
            if (isQuaTrinhHDKHKTShowing)
            {
                UserControlQuaTrinhHDKHKT UCQuaTrinhHDKHKT = listUCQuaTrinhHDKHKT[_indexQuaTrinhHDKHKT];
                if (UCQuaTrinhHDKHKT.isQuaTrinhHDKHKTOK())
                {
                    // remove previous UCQUaTrinh
                    this.RemoveQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);

                    // Increament
                    _indexQuaTrinhHDKHKT++;

                    // Add
                    this.AddQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                   MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // HoiNghiKhKT
            if (isHoiNghiKHKTShowing)
            {
                UserControlHoiNghiKHKT UCHoiNghiKHKT = listUCHoiNghiKHKT[_indexHoiNghiKHKT];
                if (UCHoiNghiKHKT.isHoiNghiKHKTOK())
                {
                    // remove previous UCHoiNghiKHKT
                    this.RemoveHoiNghiKHKT(_indexHoiNghiKHKT);

                    // Increament
                    _indexHoiNghiKHKT++;

                    // Add
                    this.AddHoiNghiKHKT(_indexHoiNghiKHKT);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    buttonTrai.Enabled = true;
                    buttonPhai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                   MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
        }

        private void buttonTrai_Click(object sender, EventArgs e)
        {
            if (isDaiHocShowing)
            {
                UserControlDaoTaoDaiHoc UCDaiHoc = listUCDaiHoc[_indexDaoTaoDaiHoc];
                // check
                if (UCDaiHoc.isDaiHocOK())
                {
                    this.RemoveDaiHoc(_indexDaoTaoDaiHoc);
                    _indexDaoTaoDaiHoc--;
                    this.AddDaiHoc(_indexDaoTaoDaiHoc);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexDaoTaoDaiHoc == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }

            // TrenDaiHoc
            if (isTrenDaiHocShowing)
            {
                UserControlTrenDaiHoc UCTrenDaiHoc = listUCTrenDaiHoc[_indexTrenDaiHoc];
                // check
                if (UCTrenDaiHoc.isTrenDaiHocOK())
                {
                    this.RemoveTrenDaiHoc(_indexTrenDaiHoc);
                    _indexTrenDaiHoc--;
                    this.AddTrenDaiHoc(_indexTrenDaiHoc);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexTrenDaiHoc == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }

            // NgoaiNgu
            if (isNgoaiNguShowing)
            {
                UserControlNgoaiNgu UCNgoaiNgu = listUCNgoaiNgu[_indexNgoaiNgu];
                // check
                if (UCNgoaiNgu.isNgoaiNguOK())
                {
                    this.RemoveNgoaiNgu(_indexNgoaiNgu);
                    _indexNgoaiNgu--;
                    this.AddNgoaiNgu(_indexNgoaiNgu);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexNgoaiNgu == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // HocHam
            if (isHocHamShowing)
            {

                UserControlHocHam UCHocHam = listUCHocHam[_indexHocHam];
                // check
                if (UCHocHam.isHocHamOK())
                {
                    this.RemoveHocHam(_indexHocHam);
                    _indexHocHam--;
                    this.AddHocHam(_indexHocHam);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexHocHam == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // KhenThuong
            if (isKhenThuongShowing)
            {

                UserControlKhenThuong UCKhenThuong = listUCKhenThuong[_indexKhenThuong];
                // check
                if (UCKhenThuong.isKhenThuongOK())
                {
                    this.RemoveKhenThuong(_indexKhenThuong);
                    _indexKhenThuong--;
                    this.AddKhenThuong(_indexKhenThuong);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexKhenThuong == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // QuaTrinh HDKHKT
            if (isQuaTrinhHDKHKTShowing)
            {

                UserControlQuaTrinhHDKHKT UCQuaTrinhHDKHKT = listUCQuaTrinhHDKHKT[_indexQuaTrinhHDKHKT];
                // check
                if (UCQuaTrinhHDKHKT.isQuaTrinhHDKHKTOK())
                {
                    this.RemoveQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);
                    _indexQuaTrinhHDKHKT--;
                    this.AddQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexQuaTrinhHDKHKT == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            // HoiNghiKHKT
            if (isHoiNghiKHKTShowing)
            {

                UserControlHoiNghiKHKT UCHoiNghiKHKT = listUCHoiNghiKHKT[_indexHoiNghiKHKT];
                // check
                if (UCHoiNghiKHKT.isHoiNghiKHKTOK())
                {
                    this.RemoveHoiNghiKHKT(_indexHoiNghiKHKT);
                    _indexHoiNghiKHKT--;
                    this.AddHoiNghiKHKT(_indexHoiNghiKHKT);

                    //update Navigation
                    this.updateNavigation();

                    // dis-enable button TraiPhai
                    if (_indexHoiNghiKHKT == 0)
                        buttonTrai.Enabled = false;
                    else
                        buttonTrai.Enabled = true;
                }
                else
                {
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_NOT_COMPLETE_MSG"), 
                        Language._("LAPHOSO_FORM_NOT_COMPLETE_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            // Ly Lich So Luoc is showing
            if (isLyLichSoLuocShowing)
            {
                if (UCLyLichSoLuoc.isLyLichSoLuocOK())
                {
                    // remove LyLichSoLuoc
                    this.RemoveLyLichSoLuoc();

                    // index of DaiHoc
                    _indexDaoTaoDaiHoc = 0;
                    isLyLichSoLuocShowing = false;
                    isDaiHocShowing = true;

                    // update Navigation
                    this.updateNavigation();


                    // Add DaoTaoDaiHoc
                    this.AddDaiHoc(0);
                }

                return;
            }
            if (isDaiHocShowing)
            {
                UserControlDaoTaoDaiHoc UCDaiHoc = listUCDaiHoc[_indexDaoTaoDaiHoc];
                if (UCDaiHoc.isDaiHocOK())
                {
                    // remove
                    this.RemoveDaiHoc(_indexDaoTaoDaiHoc);


                    // Add new
                    _indexTrenDaiHoc = 0;
                    isDaiHocShowing = false;
                    isTrenDaiHocShowing = true;

                    // update Navigation
                    this.updateNavigation();

                    this.AddTrenDaiHoc(0);
                }
                return;
            }
            if (isTrenDaiHocShowing)
            {
                UserControlTrenDaiHoc UCTrenDaiHoc = listUCTrenDaiHoc[_indexTrenDaiHoc];
                if (UCTrenDaiHoc.isTrenDaiHocOK())
                {
                    //remove
                    this.RemoveTrenDaiHoc(_indexTrenDaiHoc);

                    //addnew
                    _indexNgoaiNgu = 0;
                    isTrenDaiHocShowing = false;
                    isNgoaiNguShowing = true;

                    // update Navigation
                    this.updateNavigation();


                    this.AddNgoaiNgu(0);
                }
                return;
            }
            if (isNgoaiNguShowing)
            {
                UserControlNgoaiNgu UCNgoaiNgu = listUCNgoaiNgu[_indexNgoaiNgu];
                if (UCNgoaiNgu.isNgoaiNguOK())
                {
                    //remove
                    this.RemoveNgoaiNgu(_indexNgoaiNgu);

                    //addnew
                    _indexHocHam = 0;
                    isNgoaiNguShowing = false;
                    isHocHamShowing = true;

                    // update Navigation
                    this.updateNavigation();

                    this.AddHocHam(0);
                }
                return;
            }
            if (isHocHamShowing)
            {
                UserControlHocHam UCHocHam = listUCHocHam[_indexHocHam];
                if (UCHocHam.isHocHamOK())
                {
                    //remove
                    this.RemoveHocHam(_indexHocHam);

                    //addnew
                    _indexKhenThuong = 0;
                    isHocHamShowing = false;
                    isKhenThuongShowing = true;

                    // update Navigation
                    this.updateNavigation();


                    this.AddKhenThuong(0);
                }
                return;
            }
            // Khen Thuong
            if (isKhenThuongShowing)
            {
                UserControlKhenThuong UCKhenThuong = listUCKhenThuong[_indexKhenThuong];
                if (UCKhenThuong.isKhenThuongOK())
                {
                    //remove
                    this.RemoveKhenThuong(_indexKhenThuong);

                    //addnew
                    _indexQuaTrinhHDKHKT = 0;
                    isKhenThuongShowing = false;
                    isQuaTrinhHDKHKTShowing = true;

                    // update Navigation
                    this.updateNavigation();

                    this.AddQuaTrinhHDKHKT(0);
                }
                return;
            }


            // Qua Trinh HDKHKT
            if (isQuaTrinhHDKHKTShowing)
            {
                UserControlQuaTrinhHDKHKT UCQuTrinhHDKHKT = listUCQuaTrinhHDKHKT[_indexQuaTrinhHDKHKT];
                if (UCQuTrinhHDKHKT.isQuaTrinhHDKHKTOK())
                {
                    //remove
                    this.RemoveQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);

                    //addnew
                    _indexHoiNghiKHKT = 0;
                    isQuaTrinhHDKHKTShowing = false;
                    isHoiNghiKHKTShowing = true;

                    // update Navigation
                    this.updateNavigation();

                    this.AddHoiNghiKHKT(0);

                    //rename TiepTuc Button to LuuButton
                    btnTiepTuc.Text = Language._("LAPHOSO_FORM_LUUTOANBO_LBL");
                }
                return;
            }

            // HoiNghiKHKT
            if (isHoiNghiKHKTShowing)
            {
                UserControlHoiNghiKHKT UCHoiNghi = listUCHoiNghiKHKT[_indexHoiNghiKHKT];
                if (UCHoiNghi.isHoiNghiKHKTOK())
                {
                    // save all data
                    this.saveAll();
                    wMessageBox.Show(this, Language._("LAPHOSO_FORM_OK_MSG"), 
                        Language._("LAPHOSO_FORM_OK_MSG_TITLE"), 
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

        

        private void btnQuayLai_Click(object sender, EventArgs e)
        {

            // Ly Lich So Luoc is showing
            if (isLyLichSoLuocShowing)
            {
                // Không thể quay lại khi ở LyLichSoLuoc
                return;
            }
            if (isDaiHocShowing)
            {
                // gọi lại UCLyLichSoLuoc với index  = 0
                UserControlLyLichSoLuoc UCLyLich = UCLyLichSoLuoc;

                // remove
                this.RemoveDaiHoc(_indexDaoTaoDaiHoc);

                isDaiHocShowing = false;
                isLyLichSoLuocShowing = true;

                // update Navigation
                this.updateNavigation();

                //add New
                this.AddLyLichSoLuoc();
            }
            if (isTrenDaiHocShowing)
            {
                UserControlDaoTaoDaiHoc UCDaiHoc = listUCDaiHoc[0];


                //remove
                this.RemoveTrenDaiHoc(_indexTrenDaiHoc);

                //addnew
                _indexDaoTaoDaiHoc = 0;
                isTrenDaiHocShowing = false;
                isDaiHocShowing = true;

                // update Navigation
                this.updateNavigation();


                this.AddDaiHoc(0);

                return;
            }
            if (isNgoaiNguShowing)
            {
                UserControlTrenDaiHoc UCTrenDaiHoc = listUCTrenDaiHoc[0];

                //remove
                this.RemoveNgoaiNgu(_indexNgoaiNgu);

                //addnew
                _indexTrenDaiHoc = 0;
                isNgoaiNguShowing = false;
                isTrenDaiHocShowing = true;

                // update Navigation
                this.updateNavigation();

                this.AddTrenDaiHoc(0);
                return;
            }
            if (isHocHamShowing)
            {
                UserControlNgoaiNgu UCNgoaiNgu = listUCNgoaiNgu[0];

                //remove
                this.RemoveHocHam(_indexHocHam);

                //addnew
                _indexNgoaiNgu = 0;
                isHocHamShowing = false;
                isNgoaiNguShowing = true;

                // update Navigation
                this.updateNavigation();


                this.AddNgoaiNgu(0);
                return;
            }
            // Khen Thuong
            if (isKhenThuongShowing)
            {
                UserControlHocHam UCHocHam = listUCHocHam[0];

                //remove
                this.RemoveKhenThuong(_indexKhenThuong);

                //addnew
                _indexHocHam = 0;
                isKhenThuongShowing = false;
                isHocHamShowing = true;

                // update Navigation
                this.updateNavigation();

                this.AddHocHam(0);

                return;
            }


            // Qua Trinh HDKHKT
            if (isQuaTrinhHDKHKTShowing)
            {
                UserControlKhenThuong UCKhenThuong = listUCKhenThuong[0];
                //remove
                this.RemoveQuaTrinhHDKHKT(_indexQuaTrinhHDKHKT);

                //addnew
                _indexKhenThuong = 0;
                isQuaTrinhHDKHKTShowing = false;
                isKhenThuongShowing = true;

                // update Navigation
                this.updateNavigation();

                this.AddKhenThuong(0);

                return;
            }

            // HoiNghiKHKT
            if (isHoiNghiKHKTShowing)
            {
                // remove
                this.RemoveHoiNghiKHKT(_indexHoiNghiKHKT);

                // Add
                _indexQuaTrinhHDKHKT = 0;
                isHoiNghiKHKTShowing = false;
                isQuaTrinhHDKHKTShowing = true;

                //update
                this.updateNavigation();
                this.AddQuaTrinhHDKHKT(0);
                return;
            }

        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            DialogResult result = wMessageBox.Show(this, Language._("LOGIN_FAIL_MSG"), 
                Language._("LOGIN_FAIL_TITLE"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            if (result == System.Windows.Forms.DialogResult.Yes)
                this.Close();
        }

        private void saveAll()
        {
            //******************************************************
            // save LyLichSoLuoc
            LyLichSoLuoc _lyLichSoLuoc = UCLyLichSoLuoc.getLyLichSoLuoc();
            //_lyLichSoLuoc.Save();

            //******************************************************
            // save ID
            String _maDaoTaoDaiHoc = listUCDaiHoc[0].getInfoDaoTaoDaiHoc().maDaoTaoDaiHoc;
            String _maDaoTaoTrenDaiHoc = listUCTrenDaiHoc[0].getDaoTaoTrenDaiHoc().maDaoTaoTrenDaiHoc;
            String _maDaoTaoNgoaiNgu = listUCNgoaiNgu[0].getDaoTaoNgoaiNgu().MaDaoTaoNgoaiNgu;
            String _maDaoTaoHocHam = listUCHocHam[0].getDaoTaoHocHam().MaDaoTaoHocHam;
            String _maKhenThuong = listUCKhenThuong[0].GetKhenThuong().MaKhenThuong;
            String _maQuaTrinhHDKHKT = listUCQuaTrinhHDKHKT[0].getQuaTrinhHDKHKT().MaQuaTrinhHoatDongKHKT;
            String _maHoiNghiKHKT = listUCHoiNghiKHKT[0].getHoiNghiKHKT().MaHoiNghiKHKT;

            quaTrinhDaoTao = new QuyTrinhDaoTao(_maDaoTaoDaiHoc, _maDaoTaoTrenDaiHoc, _maDaoTaoNgoaiNgu, 
                _maDaoTaoHocHam);
            String _maQuaTrinhDaoTao = quaTrinhDaoTao.maQuaTrinhDaoTao;
            hoatDongKHKT = new HoatDongKHKT(_maQuaTrinhHDKHKT, _maHoiNghiKHKT, _maKhenThuong);
            String _maHoatDongKHKT = hoatDongKHKT.MaHoatDongKHKT;

            //******************************************************
            // Save LyLichKhoaHoc
            _lyLichSoLuoc.Save();

            // Qua Trinh DaoTao
            quaTrinhDaoTao = new QuyTrinhDaoTao(_maDaoTaoDaiHoc, _maDaoTaoTrenDaiHoc, _maDaoTaoNgoaiNgu, 
                _maDaoTaoHocHam);
            quaTrinhDaoTao.save();

            // LyLichKhoaHoc
            lyLichKhoaHoc = new LyLichKhoaHoc(_lyLichSoLuoc.maLyLichSoLuoc, _maQuaTrinhDaoTao, 
                _maHoatDongKHKT);
            lyLichKhoaHoc.save();

            // HoatDongKHKT
            hoatDongKHKT = new HoatDongKHKT(_maQuaTrinhHDKHKT, _maHoiNghiKHKT, _maKhenThuong);
            hoatDongKHKT.Save();

            

            

            // Save
            // insert into User MalyLichKhoaHoc
            QueryResult result = myDatabase.Query("UPDATE Users SET MaLyLichKhoaHoc = '"
                + lyLichKhoaHoc.maLyLichKhoaHoc
                + "' WHERE ID = '"
                + userLogin.ID + "'");

            

            

            
            //******************************************************
            // save DaoTaoDaiHoc
            foreach (UserControlDaoTaoDaiHoc _UCDaoTaoDaiHoc in listUCDaiHoc)
            {
                DaoTaoDaiHoc daiHoc = _UCDaoTaoDaiHoc.getInfoDaoTaoDaiHoc();
                daiHoc.maDaoTaoDaiHoc = _maDaoTaoDaiHoc;
                daiHoc.Save();
            }

            //******************************************************
            // save DaoTaoTrenDaiHoc
            
            foreach (UserControlTrenDaiHoc _UCTrenDaiHoc in listUCTrenDaiHoc)
            {
                DaoTaoTrenDaiHoc trenDaiHoc = _UCTrenDaiHoc.getDaoTaoTrenDaiHoc();
                trenDaiHoc.maDaoTaoTrenDaiHoc = _maDaoTaoTrenDaiHoc;
                trenDaiHoc.Save();
            }
            
            //******************************************************
            // save DaoTaoNgoaiNgu
            
            foreach (UserControlNgoaiNgu _UCNgoaiNgu in listUCNgoaiNgu)
            {
                DaoTaoNgoaiNgu ngoaiNgu = _UCNgoaiNgu.getDaoTaoNgoaiNgu();
                ngoaiNgu.MaDaoTaoNgoaiNgu = _maDaoTaoNgoaiNgu;
                ngoaiNgu.Save();
            }

            //******************************************************
            // save DaoTaoHocHam
            
            foreach (UserControlHocHam _UCHocHam in listUCHocHam)
            {
                DaoTaoHocHam hocHam = _UCHocHam.getDaoTaoHocHam();
                hocHam.MaDaoTaoHocHam = _maDaoTaoHocHam;
                hocHam.Save();
            }
            
            //******************************************************
            // save KhenThuong
            
            foreach (UserControlKhenThuong _UCKhenThuong in listUCKhenThuong)
            {
                KhenThuong khenThuong = _UCKhenThuong.GetKhenThuong();
                khenThuong.MaKhenThuong = _maKhenThuong;
                khenThuong.Save();
            }

            //******************************************************
            // save QuaTrinhHDKHKT
            
            foreach (UserControlQuaTrinhHDKHKT _UCQuaTrinhHDKHKT in listUCQuaTrinhHDKHKT)
            {
                QuaTrinhHoatDongKHKT quaTrinh = _UCQuaTrinhHDKHKT.getQuaTrinhHDKHKT();
                quaTrinh.MaQuaTrinhHoatDongKHKT = _maQuaTrinhHDKHKT;
                quaTrinh.Save();
            }

            //******************************************************
            // save HoiNghiKHKT
            
            foreach (UserControlHoiNghiKHKT _UCHoiNghiKHKT in listUCHoiNghiKHKT)
            {
                HoiNghiKHKT hoiNghiKHKT = _UCHoiNghiKHKT.getHoiNghiKHKT();
                hoiNghiKHKT.MaHoiNghiKHKT = _maHoiNghiKHKT;
                hoiNghiKHKT.Save();
            }


            //********************
            //********************
            //********************
            //********************
            //********************
            

            

           

        }
    }
}
